<?php
//TG
require_once('./security.php');

  $filename = "../includes/menu.php";
  if (file_exists($filename)) {
    // Get the contents
    $file_contents = file_get_contents($filename);
    // $file_contents = stripslashes($file_contents);
  }

  if (isset($_POST['submit1'])) { // Handle the form.
    $content = $_POST['edit'];
    $content = stripslashes($content);
    $filename = '../includes/menu.php';
    $fp = fopen($filename, "w") or die("Couldn't open $filename.");
    fwrite($fp, "$content");
    fclose($fp);
    $response = "The menu was edited.";
  }

?>

<?php $thisPage = "editmenu"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Edit the menu</title>
<meta name="robots" content="noindex,nofollow" />
<?php require_once('theme/admintheme.php');?>
</head>
<body>

<div id="wrap">



<?php include_once('navigation.php'); ?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<textarea class="textarea" name="edit" cols="70" rows="25"><?php if (isset($_POST['submit1'])) { echo stripslashes($_POST['edit']); } else { echo $file_contents; } ?></textarea><br />
<input type="submit" name="submit1" value="Edit the menu" />
</form>

<?php echo $response; ?>



</div>

</body>
</html>
